package cn.ccenjie.wsy.social.github.api;

import lombok.extern.slf4j.Slf4j;
import org.springframework.social.oauth2.AbstractOAuth2ApiBinding;
import org.springframework.social.oauth2.TokenStrategy;

@Slf4j
public class GithubImpl extends AbstractOAuth2ApiBinding implements Github {

    private static final String URL_GET_INFO = "https://api.github.com/user";

    public GithubImpl(String accessToken) {
        super(accessToken, TokenStrategy.OAUTH_TOKEN_PARAMETER);
    }

    @Override
    public GithubInfo info() {
        GithubInfo forObject = getRestTemplate().getForObject(URL_GET_INFO, GithubInfo.class);
        log.info("获取用户信息返回：{}", forObject);
        return forObject;
    }
}
